
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import { $http } from '@escook/request-miniprogram'
import store from '@/store/index.js'

Vue.config.productionTip = false
uni.$http = $http
// ​​$http.baseUrl = 'https://api.smartbird.ltd/api'
$http.baseUrl = 'https://api.smartbird.ltd/api'

App.mpType = 'app'
$http.beforeRequest = function (options) {
  uni.showLoading({title: '数据加载中...'})
  if(options.url.indexOf('/user/') !== -1) {
    options.header = {
      Authorization: store.state.m_user.token
    }
    
  }
}

// 请求完成之后做一些事情 
$http.afterRequest = function () { 
  uni.hideLoading()
  }

// 封装弹框的方法
uni.$showMsg=function(title='数据请求中',duration=1500){
	uni.showToast({
		title,
		duration,
		icon:'none'
	})
}

const app = new Vue({
    ...App,
    store
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif